home *** CD-ROM | disk | FTP | other *** search
-
- // Copyright (C) 2002 by Luigi Pino. All Rights Reserved.
-
- /***************************************************************************/
-
- #include "../library/neurosis.h"
- #include "draw.h"
- #include "file_io.h"
- #include "hiscore.h"
- #include "initialize.h"
- #include "main.h"
- #include "menu_misc.h"
- #include "paddle.h"
- #include "sphere.h"
- #include "update.h"
-
- /***************************************************************************/
-
- float ending_rotate = 0.0f;
- float ending_rotate_sign = 1.0f;
-
- extern Camera_Class camera;
- extern Light_Values_Struct light_values;
- extern Main_Menu_Class menu;
- extern Object3_Class ground_cover;
- extern Object3_Class paddle[];
- extern Object3_Class sphere[];
- extern Object4_Class ground;
- extern Object4_Class wall_net;
- extern Object4_Class wall_side;
- extern Paddle_Struct paddle_object[];
- extern Shadow_Box_Struct light_source;
- extern Sphere_Control_Struct sphere_object[];
- extern Sub_Menu_Class game_scores;
- extern Timing_Class timing;
- extern Values_Struct values;
- extern Window_Class window;
-
- extern int goal_by_team;
-
- /***************************************************************************/
-
- void Draw_Arrow(int current_sphere, float size)
-
- {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(values.fade_amount, values.fade_amount, values.fade_amount, sphere_object[current_sphere].seconds_left / 3.0f);
- glBindTexture(GL_TEXTURE_2D, window.Get_Texture(t_arrow));
-
- float3 sphere_base = sphere[current_sphere].Get_Base();
- glTranslatef(sphere_base.x, sphere_base.y, 0.0f);
- glRotatef(sphere_object[current_sphere].movement.direction, 0.0f, 0.0f, 1.0f);
-
- glBegin(GL_POLYGON);
- glTexCoord2f(0.5725f, 0.1882f);
- glVertex3f(18.0f * size, 43.0f * size, 0.1f);
- glTexCoord2f(0.3020f, 0.1490f);
- glVertex3f(-51.0f * size, 33.0f * size, 0.1f);
- glTexCoord2f(0.4392f, 0.5176f);
- glVertex3f(-16.0f * size, 127.0f * size, 0.1f);
- glTexCoord2f(0.6157f, 0.3843f);
- glVertex3f(29.0f * size, 125.0f * size, 0.1f);
- glTexCoord2f(0.6706f, 0.1843f);
- glVertex3f(43.0f * size, 42.0f * size, 0.1f);
- glEnd();
-
- glBegin(GL_POLYGON);
- glTexCoord2f(0.2196f, 0.5137f);
- glVertex3f(-72.0f * size, 126.0f * size, 0.1f);
- glTexCoord2f(0.4863f, 0.8275f);
- glVertex3f(-4.0f * size, 206.0f * size, 0.1f);
- glTexCoord2f(0.8667f, 0.5098f);
- glVertex3f(93.0f * size, 125.0f * size, 0.1f);
- glTexCoord2f(0.6157f, 0.5098f);
- glVertex3f(29.0f * size, 125.0f * size, 0.1f);
- glTexCoord2f(0.4392f, 0.5176f);
- glVertex3f(-16.0f * size, 127.0f * size, 0.1f);
- glEnd();
-
- glRotatef(-sphere_object[current_sphere].movement.direction, 0.0f, 0.0f, 1.0f);
- glTranslatef(-sphere_base.x, -sphere_base.y, 0.0f);
- glDisable(GL_BLEND);
- }
-
- /***************************************************************************/
-
- void Draw_Items()
-
- {
- float3 light_base = {0.0f, 0.0f, 0.0f};
- int x1;
-
- #ifdef _DEBUG
- if (window.keys[VK_SUBTRACT])
- {
- glPolygonMode(GL_FRONT, GL_LINE);
- glPolygonMode(GL_BACK, GL_LINE);
- }
- else
- {
- glPolygonMode(GL_FRONT, GL_FILL);
- glPolygonMode(GL_BACK, GL_FILL);
- }
- #endif
-
- if (values.game_start_fade == true)
- {
- values.fade_amount = values.fade_amount + (0.5f * timing.Get_Scale());
-
- if (values.fade_amount >= 1.0f)
- {
- values.game_start_fade = false;
- values.fade_amount = 1.0f;
- }
- }
- else if (values.game_end_fade == true)
- {
- values.fade_amount = values.fade_amount - (0.5f * timing.Get_Scale());
-
- if (values.fade_amount <= 0.0f)
- {
- values.game_end_fade = false;
- values.fade_amount = 0.0f;
- menu.Set_Current(&game_scores);
- values.game_position = Game_Menu;
- }
- }
-
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, camera.zoom_current);
- glRotatef(camera.axis_current.x, 1.0f, 0.0f, 0.0f);
- glRotatef(camera.axis_current.z, 0.0f, 0.0f, 1.0f);
-
- // Draw ground cover
- ground_cover.Color();
-
- // Draw ground
- ground.Initialize_Light();
- ground.Calculate_Light(&light_source);
- ground.Finalize_Light();
- ground.Fade(values.fade_amount);
- ground.Draw();
-
- // Draw arrows
- for (x1=0;x1<values.sphere_number;x1=x1+1)
- {
- if (sphere_object[x1].goal == true)
- {
- if (values.sphere_number == 1)
- Draw_Arrow(x1, 0.3333f);
- else
- Draw_Arrow(x1, 0.1833f);
- }
- }
-
- if (values.game_type == Timed)
- Update_Current_Light_Point();
-
- // Initialize light source
- light_source.position.x = light_values.distance_current;
- light_source.position.y = 0.0f;
- Rotate_z(&light_base, &light_source.position, light_values.rotate_current);
-
- // Draw spheres
- for (x1=0;x1<values.sphere_number;x1=x1+1)
- {
- sphere[x1].Initialize_Light();
- sphere[x1].Calculate_Light(&light_source);
- sphere[x1].Finalize_Light();
- sphere[x1].Fade(values.fade_amount);
- sphere[x1].Rotate_z(-sphere_object[x1].movement.direction);
- sphere[x1].Rotate_y(-sphere_object[x1].movement.speed / 25.0f);
- sphere[x1].Rotate_z(sphere_object[x1].movement.direction);
- sphere[x1].Draw();
- }
-
- // Draw paddles
- for (x1=Up;x1<=Right;x1=x1+1)
- if (paddle_object[x1].game_over == false)
- {
- paddle[x1].Initialize_Light();
- paddle[x1].Calculate_Light(&light_source);
- paddle[x1].Finalize_Light();
- paddle[x1].Fade(values.fade_amount);
- paddle[x1].Draw();
-
- // Make sure time doesn't count during fadeout
- if ((values.seconds_left >= 0.0f) || (values.game_type == Countdown))
- paddle_object[x1].time_lapse = paddle_object[x1].time_lapse + timing.Get_Scale();
-
- if ((values.game_type == Countdown) && (goal_by_team == x1))
- paddle_object[x1].score = paddle_object[x1].score - (3.0f * timing.Get_Scale());
- }
-
- // Draw Wall
- if (camera.axis_current.x < 300.0f)
- {
- for (x1=0;x1<wall_net.Get_Size();x1=x1+1)
- wall_net.Set_Alpha(x1, 1.0f - ((300.0f - camera.axis_current.x) * 0.02f));
- for (x1=0;x1<wall_side.Get_Size();x1=x1+1)
- wall_side.Set_Alpha(x1, 1.0f - ((300.0f - camera.axis_current.x) * 0.02f));
- }
-
- wall_net.Initialize_Light();
- wall_net.Calculate_Light(&light_source);
- wall_net.Finalize_Light();
- wall_net.Fade(values.fade_amount);
- wall_net.Draw();
- wall_side.Initialize_Light();
- wall_side.Calculate_Light(&light_source);
- wall_side.Finalize_Light();
- wall_side.Fade(values.fade_amount);
- wall_side.Draw();
-
- // Draw score behind paddles
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if (paddle_object[x1].game_over == false)
- {
- if (x1 == Up)
- {
- Draw_Score(Up, true);
- Draw_Score(Up, false);
- }
- else if (x1 == Down)
- {
- Draw_Score(Down, true);
- Draw_Score(Down, false);
- }
- else if (x1 == Left)
- {
- Draw_Score(Left, true);
- Draw_Score(Left, false);
- }
- else if (x1 == Right)
- {
- Draw_Score(Right, true);
- Draw_Score(Right, false);
- }
- }
- }
-
- #ifdef _DEBUG
- window.Font_Begin();
- window.Font_Int((int)(1.0f / timing.Get_Scale()), 290.0f, -220.0f, 10.0f, R_4, G_4, B_4);
- window.Font_Int(window.polygon_number, -310, -220.0f, 10.0f, R_4, G_4, B_4);
- window.polygon_number = 0;
- window.Font_End();
- #endif
- }
-
- /***************************************************************************/
-
- void Draw_Score(int net, bool front)
-
- {
- char temp;
- char word[20];
- float counter = 0.0f;
- float size = 33.0f;
- float x = 0.0f;
- float y = 0.0f;
- float x_percent;
- float y_percent;
- float x_left = 0.0f;
- float x_right = 0.0f;
- float y_left = 0.0f;
- float y_right = 0.0f;
- float z_top = 0.0f;
- float z_bottom = 0.0f;
- int length;
-
- _itoa((int)(paddle_object[net].score), word, 10);
- length = strlen(word);
-
- if (((front == false) && (net == Up)) || ((front == true) && (net == Down)) || ((front == false) && (net == Left)) ||
- ((front == true) && (net == Right)))
-
- {
- for (int x1=0;x1<length/2;x1=x1+1)
- {
- temp = word[length - 1 - x1];
- word[length - 1 - x1] = word[x1];
- word[x1] = temp;
- }
- }
-
- if (net == Up)
- {
- x = 0.0f - (length * 17.0f);
- y_left = 0.0f;
- y_right = 0.0f;
- z_top = 33.0f;
- z_bottom = 0.0f;
-
- if (front == true)
- y = 189.0f;
- else
- y = 191.0f;
- }
- else if (net == Down)
- {
- x = 0.0f - (length * 17.0f);
- y_left = 0.0f;
- y_right = 0.0f;
- z_top = 33.0f;
- z_bottom = 0.0f;
-
- if (front == true)
- y = -189.0f;
- else
- y = -191.0f;
- }
- else if (net == Left)
- {
- y = 0.0f - (length * 17.0f);
- x_left = 0.0f;
- x_right = 0.0f;
- z_top = 33.0f;
- z_bottom = 0.0f;
-
- if (front == true)
- x = -189.0f;
- else
- x = -191.0f;
- }
- else if (net == Right)
- {
- y = 0.0f - (length * 17.0f);
- x_left = 0.0f;
- x_right = 0.0f;
- z_top = 33.0f;
- z_bottom = 0.0f;
-
- if (front == true)
- x = 189.0f;
- else
- x = 191.0f;
- }
-
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, camera.zoom_current);
- glRotatef(camera.axis_current.x, 1.0f, 0.0f, 0.0f);
- glRotatef(camera.axis_current.z, 0.0f, 0.0f, 1.0f);
- glTranslatef(x, y, 8.0f);
-
- glEnable(GL_BLEND);
-
- while (counter < length)
- {
- if (net == Up)
- {
- if (front == true)
- {
- x_left = (size * counter) - (2.5f * counter);
- x_right = (size * (1.0f + counter)) - (2.5f * counter);
- }
- else
- {
- x_left = (size * (1.0f + counter)) - (2.5f * counter);
- x_right = (size * counter) - (2.5f * counter);
- }
- }
- else if (net == Down)
- {
- if (front == true)
- {
- x_left = (size * (1.0f + counter)) - (2.5f * counter);
- x_right = (size * counter) - (2.5f * counter);
- }
- else
- {
- x_left = (size * counter) - (2.5f * counter);
- x_right = (size * (1.0f + counter)) - (2.5f * counter);
- }
- }
- else if (net == Left)
- {
- if (front == true)
- {
- y_left = (size * counter) - (2.5f * counter);
- y_right = (size * (1.0f + counter)) - (2.5f * counter);
- }
- else
- {
- y_left = (size * (1.0f + counter)) - (2.5f * counter);
- y_right = (size * counter) - (2.5f * counter);
- }
- }
- else if (net == Right)
- {
- if (front == true)
- {
- y_left = (size * (1.0f + counter)) - (2.5f * counter);
- y_right = (size * counter) - (2.5f * counter);
- }
- else
- {
- y_left = (size * counter) - (2.5f * counter);
- y_right = (size * (1.0f + counter)) - (2.5f * counter);
- }
- }
-
- x_percent = 0.5f;
- y_percent = 0.5f;
-
- switch (word[(int)(counter)])
- {
- case 48 : x_percent = 0.250f; y_percent = 0.625f; break; // 0
- case 49 : x_percent = 0.375f; y_percent = 0.625f; break; // 1
- case 50 : x_percent = 0.500f; y_percent = 0.625f; break; // 2
- case 51 : x_percent = 0.625f; y_percent = 0.625f; break; // 3
- case 52 : x_percent = 0.750f; y_percent = 0.625f; break; // 4
- case 53 : x_percent = 0.875f; y_percent = 0.625f; break; // 5
- case 54 : x_percent = 0.000f; y_percent = 0.500f; break; // 6
- case 55 : x_percent = 0.125f; y_percent = 0.500f; break; // 7
- case 56 : x_percent = 0.250f; y_percent = 0.500f; break; // 8
- case 57 : x_percent = 0.375f; y_percent = 0.500f; break; // 9
- }
-
- glBlendFunc(GL_DST_COLOR, GL_ZERO);
-
- glBindTexture(GL_TEXTURE_2D, window.Get_Texture(t_font_mask));
- glColor3f(1.0f, 1.0f, 1.0f);
-
- glBegin(GL_QUADS);
- glTexCoord2f(x_percent, y_percent);
- glVertex3f(x_left, y_left, z_top);
- glTexCoord2f(x_percent + 0.125f, y_percent);
- glVertex3f(x_right, y_right, z_top);
- glTexCoord2f(x_percent + 0.125f, y_percent - 0.125f);
- glVertex3f(x_right, y_right, z_bottom);
- glTexCoord2f(x_percent, y_percent - 0.125f);
- glVertex3f(x_left, y_left, z_bottom);
- glEnd();
-
- glBlendFunc(GL_ONE, GL_ONE);
-
- glBindTexture(GL_TEXTURE_2D, window.Get_Texture(t_font));
- glColor3f(0.0f * values.fade_amount, 0.8863f * values.fade_amount, 0.1255f * values.fade_amount);
-
- glBegin(GL_QUADS);
- glTexCoord2f(x_percent, y_percent);
- glVertex3f(x_left, y_left, z_top);
- glTexCoord2f(x_percent + 0.125f, y_percent);
- glVertex3f(x_right, y_right, z_top);
- glTexCoord2f(x_percent + 0.125f, y_percent - 0.125f);
- glVertex3f(x_right, y_right, z_bottom);
- glTexCoord2f(x_percent, y_percent - 0.125f);
- glVertex3f(x_left, y_left, z_bottom);
- glEnd();
-
- counter = counter + 1.0f;
- }
-
- glDisable(GL_BLEND);
- }
-
- /***************************************************************************/
-
- void Ending()
-
- {
- float3 image_base = {-270.0f, -200.0f, 0.0f};
- float3 point_up_left = {-320.0f, 200.0f, 0.0f};
- float3 point_up_right = {200.0f, 200.0f, 0.0f};
- float3 point_down_right = {200.0f, -240.0f, 0.0f};
- float3 point_down_left = {-320.0f, -240.0f, 0.0f};
-
- if (values.fade_amount < 1.0f)
- values.fade_amount = values.fade_amount + (0.4f * timing.Get_Scale());
- else
- values.fade_amount = 1.0f;
-
- Quad_Color(-320.0f, 240.0f, 0.0f, 320.0f, 240.0f, 0.0f, 320.0f, -245.0f, 0.0f, -320.0f, -245.0f, 0.0f,
- (165.0f / 255.0f) * values.fade_amount, (165.0f / 255.0f) * values.fade_amount, (165.0f / 255.0f) * values.fade_amount, 1.0f);
-
- if ((window.keys[VK_ESCAPE]) || (window.keys[VK_RETURN]))
- window.quit_game = true;
-
- Rotate_z(&image_base, &point_up_left, ending_rotate);
- Rotate_z(&image_base, &point_up_right, ending_rotate);
- Rotate_z(&image_base, &point_down_right, ending_rotate);
- Rotate_z(&image_base, &point_down_left, ending_rotate);
-
- ending_rotate = ending_rotate + (ending_rotate_sign * 30.0f * timing.Get_Scale());
-
- if (ending_rotate > 20.0f)
- ending_rotate_sign = -1.0f;
- else if (ending_rotate < -10.0f)
- ending_rotate_sign = 1.0f;
-
- Quad_Texture(t_menu_1, point_up_left.x, point_up_left.y, 0.0f, point_up_right.x, point_up_right.y, 0.0f,
- point_down_right.x, point_down_right.y, 0.0f, point_down_left.x, point_down_left.y, 0.0f,
- 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, values.fade_amount, values.fade_amount, values.fade_amount);
- Quad_Texture(t_menu_2, 50.0f, 80.0f, 0.0f, 300.0f, 80.0f, 0.0f, 300.0f, -170.0f, 0.0f, 50.0f, -170.0f, 0.0f,
- 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, values.fade_amount, values.fade_amount, values.fade_amount);
-
- window.Font_Char("SPHERICAL VENGEANCE", -280.0f, 180.0f, 30.0f, R_9, G_9, B_9);
- window.Font_Char("THE 23RD DIMENSION - LP23.COM", -140.0f, 140.0f, 15.0f, R_4, G_4, B_4);
- window.Font_Char("E-MAIL:", -50.0f, -140.0f, 20.0f, R_5, G_5, B_5);
- window.Font_Char("MAIL@LP23.COM", -50.0f, -170.0f, 15.0f, R_5, G_5, B_5);
- }
-
- /***************************************************************************/
-
- void Intro()
-
- {
- Quad_Color(-320.0f, 240.0f, 0.0f, 320.0f, 240.0f, 0.0f, 320.0f, -240.0f, 0.0f, -320.0f, -240.0f, 0.0f,
- values.fade_amount, values.fade_amount, values.fade_amount, 1.0f);
-
- if (values.intro_count < 30.0f)
- {
- Quad_Texture(t_menu_1, -150.0f, 150.0f, 0.0f, 150.0f, 150.0f, 0.0f, 150.0f, -150.0f, 0.0f, -150.0f, -150.0f, 0.0f,
- 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, values.fade_amount, values.fade_amount, values.fade_amount);
-
- if (values.fade_amount < 1.0f)
- values.fade_amount = values.fade_amount + (0.4f * timing.Get_Scale());
- else
- values.fade_amount = 1.0f;
- }
- else if (values.intro_count < 60.0f)
- {
- Quad_Texture(t_menu_2, -150.0f, 150.0f, 0.0f, 150.0f, 150.0f, 0.0f, 150.0f, -150.0f, 0.0f, -150.0f, -150.0f, 0.0f,
- 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
- }
- else if (values.intro_count < 88.0f)
- {
- Quad_Texture(t_menu_3, -150.0f, 150.0f, 0.0f, 150.0f, 150.0f, 0.0f, 150.0f, -150.0f, 0.0f, -150.0f, -150.0f, 0.0f,
- 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, values.fade_amount, values.fade_amount, values.fade_amount);
-
- values.fade_amount = values.fade_amount - (0.4f * timing.Get_Scale());
- }
- else
- {
- values.fade_amount = 0.0f;
- values.game_position = Game_Menu;
- window.Load_Texture(t_menu_1, "Data/menu_1.bmp");
- window.Load_Texture(t_menu_2, "Data/menu_2.bmp");
- }
-
- if ((window.keys[VK_ESCAPE]) || (window.keys[VK_RETURN]))
- {
- values.fade_amount = 0.0f;
- values.game_position = Game_Menu;
- window.Load_Texture(t_menu_1, "Data/menu_1.bmp");
- window.Load_Texture(t_menu_2, "Data/menu_2.bmp");
- window.keys[VK_ESCAPE] = false;
- window.keys[VK_RETURN] = false;
- }
-
- values.intro_count = values.intro_count + (10.0f * timing.Get_Scale());
- }
-
- /***************************************************************************/